package com.runa.rccprotocol.dto.param;

/**
 * 测点档案
 */
public class IndexRecord extends Param {

    private int index;

    private byte port;

    private byte code;

    private String address;

    private String doorplate;

    private float area;

    private boolean isFt;

    private int sign;

    private byte type;

    @Override
    public void setIndex(int index) {
        this.index = index;
    }

    @Override
    public int getIndex() {
        return index;
    }

    public byte getPort() {
        return port;
    }

    public void setPort(int port) {
        this.port = (byte) port;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = (byte) code;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getDoorplate() {
        return doorplate;
    }

    public void setDoorplate(String doorplate) {
        this.doorplate = doorplate;
    }

    public float getArea() {
        return area;
    }

    public void setArea(float area) {
        this.area = area;
    }

    public int getSign() {
        return sign;
    }

    public void setSign(int sign) {
        this.sign = sign;
    }

    public byte getType() {
        return type;
    }

    public void setType(int bigType) {
        this.type = (byte) bigType;
    }

    public boolean isFt() {
        return isFt;
    }

    public void setFt(boolean ft) {
        isFt = ft;
    }

    public byte[] getBytes() {
        byte[] bs = new byte[22];
        bs[0] = (byte) index;
        bs[1] = (byte) (index >> 8);    //序号
        bs[2] = (byte) index;
        bs[3] = (byte) (index >> 8);    //测量点
        bs[4] = port;                   //端口
        bs[5] = code;                   //规约
        dataFormat12(address, bs, 6);   //地址
        dataFormat12(doorplate, bs, 12);//门牌
        dataFormat7(area, bs, 18);      //面积
        bs[20] = (byte) ((isFt?1:0) + ((sign&0x0f)<<4));                  //小类与分摊标志
        bs[21] = type;               //大类
        return bs;
    }
}
